//
//  CCKPubMoreModel.m
//  budejieMe
//
//  Created by 韦恺 on 16/8/27.
//  Copyright © 2016年 SuperJJ. All rights reserved.
//

#import "CCKPubMoreModel.h"

@implementation CCKPubMoreModel

+ (instancetype)pubMoreWithDict:(NSDictionary *)dict
{
    CCKPubMoreModel *model = [self new];
    [model setValuesForKeysWithDictionary:dict];
    return model;
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    
}

+ (void)downloadPubMoreDataWithUrl:(NSString *)url successBlock:(void (^)(NSArray *dataArr))successBlock failBlock:(void (^)(NSError *error))failBlock
{
    [[AFHTTPSessionManager manager] GET:url parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, NSDictionary *responseObject) {
       
        NSArray *dataArr = responseObject[@"list"];
        NSMutableArray *arrM = [NSMutableArray arrayWithCapacity:dataArr.count];
        
        [dataArr enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
           
            [arrM addObject:[self pubMoreWithDict:obj]];
        }];
        
        if (successBlock) {
            successBlock(arrM.copy);
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
        if (failBlock) {
            failBlock(error);
        }
    }];
}

@end
